using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class Forums_TopicMap : EntityTypeConfiguration<Forums_Topic>
    {
        public Forums_TopicMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Subject)
                .IsRequired()
                .HasMaxLength(450);

            // Table & Column Mappings
            this.ToTable("Forums_Topic");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ForumId).HasColumnName("ForumId");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.TopicTypeId).HasColumnName("TopicTypeId");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.NumPosts).HasColumnName("NumPosts");
            this.Property(t => t.Views).HasColumnName("Views");
            this.Property(t => t.LastPostId).HasColumnName("LastPostId");
            this.Property(t => t.LastPostCustomerId).HasColumnName("LastPostCustomerId");
            this.Property(t => t.LastPostTime).HasColumnName("LastPostTime");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");
            this.Property(t => t.UpdatedOnUtc).HasColumnName("UpdatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.Forums_Topic)
                .HasForeignKey(d => d.CustomerId);
            this.HasRequired(t => t.Forums_Forum)
                .WithMany(t => t.Forums_Topic)
                .HasForeignKey(d => d.ForumId);

        }
    }
}
